export default {
  //初始数据
  getData(state, payload) {
    state.dataList = payload;
  },
  //加加减减
  addFn(state, payload) {
    let totalNum = 0;
    let total = 0; //总价
    state.dataList.map(item => {
      let sum = 0;
      if (item.id == payload.index) {
        //找到对应的对象，更改数量
        item.items.map(v => {
          if (v.uid == payload.ind) {
            v.num = payload.num;
          }
        });
        item.items.map(k => (sum += k.num));
        item.numm = sum;
      }
      totalNum += item.numm;
      //计算总价
      item.items.map(H => (total += H.num * H.pic));
    });
    state.total = total;
    state.totalNum = totalNum;
  },
  //显示隐藏
  changeIsShow(state,payload){
    state.Show=payload
  }
};
